package com.atguigu.yygh.hosp.controller;

import com.atguigu.yygh.common.model.hosp.Schedule;
import com.atguigu.yygh.common.result.Result;
import com.atguigu.yygh.common.vo.hosp.ScheduleOrderVo;
import com.atguigu.yygh.hosp.service.ScheduleService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * @author LY
 * 排班接口
 */
@Api(tags = "排班管理接口")
@RestController
@RequestMapping("/admin/hosp/schedule")
//@CrossOrigin
public class ScheduleController {

    @Autowired
    private ScheduleService scheduleService;

    @ApiOperation(value = "根据排班id获取预约下单数据")
    @GetMapping("inner/getScheduleOrderVo/{scheduleId}")
    public ScheduleOrderVo getScheduleOrderVo(@ApiParam(name = "scheduleId", value = "排班id", required = true)
                                                  @PathVariable("scheduleId") String scheduleId) {
        return scheduleService.getScheduleOrderVo(scheduleId);
    }

    @ApiOperation(value = "查询排班规则数据")
    @GetMapping("getScheduleRule/{page}/{limit}/{hoscode}/{depcode}")
    public Result getScheduleRule(@PathVariable long page,
                                  @PathVariable long limit,
                                  @PathVariable String hoscode,
                                  @PathVariable String depcode){

        Map<String,Object> map = scheduleService.getRuleSchedule(page,limit,hoscode,depcode);

        return Result.ok(map);
    }

    @ApiOperation(value = "查询排班详情")
    @GetMapping("getScheduleDetail/{hoscode}/{depcode}/{workDate}")
    public Result getScheduleDetail( @PathVariable String hoscode,
                                     @PathVariable String depcode,
                                     @PathVariable String workDate){

       List<Schedule> scheduleList =  scheduleService.getDetailSchedule(hoscode,depcode,workDate);

       return Result.ok(scheduleList);
    }
}
